﻿
namespace SampleDataGenerator
{
    using System.IO;
    using System.Linq;
    using CoProjectModel;

    class Program
    {

        /// <summary>
        /// Simple Console Program to create some XML data from the real database.
        /// To Run, set this project to StartUp and run. It will make an uptodate version
        /// of the SampleData.xml file. 
        /// 
        /// The file is linked to CoProjectModel.SL so that an alternative EntityManager
        /// can be used to load this data, both in Design mode and running when Debugging.
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            var manager = new CoProjectEntities();

            // Populate the entity manager cache with data
            // Only add the entities that are currently viewable ia the app.
            var users = manager.Users.ToList();
            var todolists = manager.ToDoLists.ToList();
            var todoitems = manager.ToDoItems.ToList();

            using (var fileStream = new FileStream(@"..\..\SampleData.xml", FileMode.Create))
            {
                manager.CacheStateManager.SaveCacheState(fileStream, useBinaryFormat: false);
            }
        }
    }
}
